home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / Goodies / NAMESP~1 / NSTREE.FR_ / NSTREE.FR
Text File  |  1997-06-04  |  14KB  |  447 lines

  1. VERSION 5.00
  2. Object = "{721C2D87-B82E-11D0-B8ED-00608CC9A71F}#1.0#0"; "Awnsctrl.ocx"
  3. Begin VB.Form frmNSTreeDemo 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "ActiveX NameSpaceTree Control Demo"
  6.    ClientHeight    =   6840
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   8760
  10.    Icon            =   "NSTree.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    PaletteMode     =   1  'UseZOrder
  15.    ScaleHeight     =   6840
  16.    ScaleWidth      =   8760
  17.    ShowInTaskbar   =   0   'False
  18.    Begin VB.CommandButton cmdClose 
  19.       Caption         =   "Close"
  20.       Height          =   315
  21.       Left            =   7260
  22.       TabIndex        =   24
  23.       Top             =   720
  24.       Width           =   1335
  25.    End
  26.    Begin VB.Frame fraSelFolder 
  27.       Caption         =   "Selected Folder"
  28.       Height          =   2415
  29.       Left            =   120
  30.       TabIndex        =   14
  31.       Top             =   2340
  32.       Width           =   3675
  33.       Begin VB.CommandButton cmdPath 
  34.          Caption         =   "Path:"
  35.          Height          =   315
  36.          Left            =   60
  37.          TabIndex        =   21
  38.          Top             =   1080
  39.          Width           =   615
  40.       End
  41.       Begin VB.CommandButton cmdSave 
  42.          Caption         =   "Save Folder"
  43.          Height          =   315
  44.          Left            =   120
  45.          TabIndex        =   20
  46.          Top             =   240
  47.          Width           =   1515
  48.       End
  49.       Begin VB.CommandButton cmdRestore 
  50.          Caption         =   "Resore Folder"
  51.          Height          =   315
  52.          Left            =   1980
  53.          TabIndex        =   19
  54.          Top             =   240
  55.          Width           =   1575
  56.       End
  57.       Begin VB.Label lblFolderIDL 
  58.          Caption         =   "FolderIDL:"
  59.          Height          =   915
  60.          Left            =   120
  61.          TabIndex        =   18
  62.          Top             =   1440
  63.          Width           =   3435
  64.       End
  65.       Begin VB.Label lblFolderAttributes 
  66.          Caption         =   "FolderAttributes:"
  67.          Height          =   195
  68.          Left            =   120
  69.          TabIndex        =   17
  70.          Top             =   840
  71.          Width           =   3075
  72.       End
  73.       Begin VB.Label lblPath 
  74.          Caption         =   "lblPath"
  75.          Height          =   195
  76.          Left            =   780
  77.          TabIndex        =   16
  78.          Top             =   1140
  79.          Width           =   2715
  80.       End
  81.       Begin VB.Label lblFolderName 
  82.          Caption         =   "FolderName:"
  83.          Height          =   195
  84.          Left            =   120
  85.          TabIndex        =   15
  86.          Top             =   600
  87.          Width           =   3075
  88.       End
  89.    End
  90.    Begin VB.Frame fraAppearance 
  91.       Caption         =   "Appearance"
  92.       Height          =   1515
  93.       Left            =   120
  94.       TabIndex        =   8
  95.       Top             =   780
  96.       Width           =   3675
  97.       Begin VB.CheckBox chkAppearance 
  98.          Caption         =   "Appearance 3D"
  99.          Height          =   195
  100.          Left            =   120
  101.          TabIndex        =   13
  102.          Top             =   240
  103.          Value           =   1  'Checked
  104.          Width           =   1935
  105.       End
  106.       Begin VB.CheckBox chkBorderStyle 
  107.          Caption         =   "BorderStyle"
  108.          Height          =   195
  109.          Left            =   120
  110.          TabIndex        =   12
  111.          Top             =   480
  112.          Value           =   1  'Checked
  113.          Width           =   1935
  114.       End
  115.       Begin VB.CheckBox chkEnabled 
  116.          Caption         =   "Enabled"
  117.          Height          =   195
  118.          Left            =   120
  119.          TabIndex        =   11
  120.          Top             =   720
  121.          Value           =   1  'Checked
  122.          Width           =   1275
  123.       End
  124.       Begin VB.CheckBox chkHideSelection 
  125.          Caption         =   "HideSelection"
  126.          Height          =   195
  127.          Left            =   120
  128.          TabIndex        =   10
  129.          Top             =   960
  130.          Width           =   1935
  131.       End
  132.       Begin VB.CheckBox chkIncludeHiddenSystem 
  133.          Caption         =   "IncludeHiddenSystem"
  134.          Height          =   195
  135.          Left            =   120
  136.          TabIndex        =   9
  137.          Top             =   1200
  138.          Width           =   2535
  139.       End
  140.    End
  141.    Begin VB.Frame fraRoot 
  142.       Caption         =   "Root Folder"
  143.       Height          =   1875
  144.       Left            =   120
  145.       TabIndex        =   3
  146.       Top             =   4800
  147.       Width           =   3675
  148.       Begin VB.CommandButton cmdRootDIR 
  149.          Caption         =   "RootDIR:"
  150.          Height          =   315
  151.          Left            =   60
  152.          TabIndex        =   22
  153.          Top             =   600
  154.          Width           =   855
  155.       End
  156.       Begin VB.ComboBox cboRootSFN 
  157.          Height          =   315
  158.          Left            =   900
  159.          Style           =   2  'Dropdown List
  160.          TabIndex        =   5
  161.          Top             =   240
  162.          Width           =   2655
  163.       End
  164.       Begin VB.Label lblRootIDL 
  165.          Caption         =   "RootIDL:"
  166.          Height          =   855
  167.          Left            =   120
  168.          TabIndex        =   7
  169.          Top             =   960
  170.          Width           =   3315
  171.       End
  172.       Begin VB.Label lblRootSFN 
  173.          Caption         =   "RootSFN:"
  174.          Height          =   195
  175.          Left            =   120
  176.          TabIndex        =   6
  177.          Top             =   300
  178.          Width           =   675
  179.       End
  180.       Begin VB.Label lblRootDIR 
  181.          Caption         =   "lblRootDIR"
  182.          Height          =   195
  183.          Left            =   1020
  184.          TabIndex        =   4
  185.          Top             =   660
  186.          Width           =   2535
  187.       End
  188.    End
  189.    Begin VB.TextBox txtEvents 
  190.       Height          =   1815
  191.       Left            =   3960
  192.       Locked          =   -1  'True
  193.       MultiLine       =   -1  'True
  194.       ScrollBars      =   2  'Vertical
  195.       TabIndex        =   1
  196.       Top             =   4860
  197.       Width           =   4635
  198.    End
  199.    Begin AWNSCTRL.NSTree NSTree 
  200.       Height          =   3435
  201.       Left            =   3960
  202.       TabIndex        =   0
  203.       Top             =   1140
  204.       Width           =   4635
  205.       _ExtentX        =   8176
  206.       _ExtentY        =   6059
  207.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  208.          Name            =   "MS Sans Serif"
  209.          Size            =   8.25
  210.          Charset         =   0
  211.          Weight          =   400
  212.          Underline       =   0   'False
  213.          Italic          =   0   'False
  214.          Strikethrough   =   0   'False
  215.       EndProperty
  216.       HideSelection   =   0   'False
  217.       MouseIcon       =   "NSTree.frx":000C
  218.    End
  219.    Begin VB.Label lblNSTree 
  220.       Caption         =   "NameSpaceTree Control:"
  221.       Height          =   195
  222.       Left            =   3960
  223.       TabIndex        =   25
  224.       Top             =   840
  225.       Width           =   2895
  226.    End
  227.    Begin VB.Label lblTitle 
  228.       Alignment       =   2  'Center
  229.       BackColor       =   &H00000000&
  230.       BorderStyle     =   1  'Fixed Single
  231.       Caption         =   "Acuteware NameSpaceTree"
  232.       BeginProperty Font 
  233.          Name            =   "Arial"
  234.          Size            =   24
  235.          Charset         =   0
  236.          Weight          =   700
  237.          Underline       =   0   'False
  238.          Italic          =   -1  'True
  239.          Strikethrough   =   0   'False
  240.       EndProperty
  241.       ForeColor       =   &H00FFFFFF&
  242.       Height          =   675
  243.       Left            =   0
  244.       TabIndex        =   23
  245.       Top             =   0
  246.       Width           =   8775
  247.    End
  248.    Begin VB.Label lblEvents 
  249.       Caption         =   "Events:"
  250.       Height          =   195
  251.       Left            =   3960
  252.       TabIndex        =   2
  253.       Top             =   4620
  254.       Width           =   1455
  255.    End
  256. End
  257. Attribute VB_Name = "frmNSTreeDemo"
  258. Attribute VB_GlobalNameSpace = False
  259. Attribute VB_Creatable = False
  260. Attribute VB_PredeclaredId = True
  261. Attribute VB_Exposed = False
  262. Option Explicit
  263. Private mvIDL As Variant
  264.  
  265. Private Sub cboRootSFN_Click()
  266.     If cboRootSFN.ListIndex <> -1 Then
  267.         NSTree.RootSFN = cboRootSFN.ItemData(cboRootSFN.ListIndex)
  268.         Call ShowProperies
  269.     End If
  270. End Sub
  271.  
  272. Private Sub chkAppearance_Click()
  273.     NSTree.Appearance = chkAppearance
  274. End Sub
  275.  
  276. Private Sub chkBorderStyle_Click()
  277.     NSTree.BorderStyle = chkBorderStyle
  278. End Sub
  279.  
  280. Private Sub chkEnabled_Click()
  281.     NSTree.Enabled = (chkEnabled = vbChecked)
  282. End Sub
  283.  
  284. Private Sub chkHideSelection_Click()
  285.     NSTree.HideSelection = (chkHideSelection = vbChecked)
  286. End Sub
  287.  
  288. Private Sub chkIncludeHiddenSystem_Click()
  289.     NSTree.IncludeHiddenSystem = (chkIncludeHiddenSystem = vbChecked)
  290. End Sub
  291.  
  292.  
  293. Private Sub cmdClose_Click()
  294.     Unload Me
  295. End Sub
  296.  
  297. Private Sub cmdPath_Click()
  298.     Dim sPath As String
  299.     
  300.     sPath = InputBox("Enter the Folder Directory (Path):", "Folder Directory", NSTree.Path)
  301.     If Len(sPath) = 0 Then Exit Sub
  302.    
  303.     On Error Resume Next
  304.     NSTree.Path = sPath
  305.     If Err Then MsgBox Err.Description, vbInformation
  306.     Call ShowProperies
  307. End Sub
  308.  
  309. Private Sub cmdRestore_Click()
  310.     If Not IsEmpty(mvIDL) Then NSTree.FolderIDL = mvIDL
  311. End Sub
  312.  
  313. Private Sub cmdRootDIR_Click()
  314.     Dim sPath As String
  315.     
  316.     sPath = InputBox("Enter a Root Directory:", "Root Directory", NSTree.RootDIR)
  317.     If Len(sPath) = 0 Then Exit Sub
  318.    
  319.     On Error Resume Next
  320.     NSTree.RootDIR = sPath
  321.     If Err Then MsgBox Err.Description, vbInformation
  322.     Call ShowProperies
  323. End Sub
  324.  
  325. Private Sub cmdSave_Click()
  326.     mvIDL = NSTree.FolderIDL
  327. End Sub
  328.  
  329. Private Sub Form_Load()
  330.     Me.Move 0, 0
  331.     
  332.     Call ComboRootAdd("sfnDesktopNS", sfnDesktopNS)
  333.     Call ComboRootAdd("sfnProgramsDir", sfnProgramsDir)
  334.     Call ComboRootAdd("sfnControlPanelNS", sfnControlPanelNS)
  335.     Call ComboRootAdd("sfnPrintersNS", sfnPrintersNS)
  336.     Call ComboRootAdd("sfnMyDocumentsDir", sfnMyDocumentsDir)
  337.     Call ComboRootAdd("sfnFavoritesDir", sfnFavoritesDir)
  338.     Call ComboRootAdd("sfnStartUpDir", sfnStartUpDir)
  339.     Call ComboRootAdd("sfnRecentDir", sfnRecentDir)
  340.     Call ComboRootAdd("sfnSendToDir", sfnSendToDir)
  341.     Call ComboRootAdd("sfnRecycleBinNS", sfnRecycleBinNS)
  342.     Call ComboRootAdd("sfnStartMenuDir", sfnStartMenuDir)
  343.     Call ComboRootAdd("sfnDesktopDir", sfnDesktopDir)
  344.     Call ComboRootAdd("sfnMyComputerNS", sfnMyComputerNS)
  345.     Call ComboRootAdd("sfnNetworkNeighborhoodNS", sfnNetworkNeighborhoodNS)
  346.     Call ComboRootAdd("sfnNetHoodDir", sfnNetHoodDir)
  347.     Call ComboRootAdd("sfnFontsDir", sfnFontsDir)
  348.     Call ComboRootAdd("sfnShellNewDir", sfnShellNewDir)
  349.     
  350.     Call ShowProperies
  351. End Sub
  352.  
  353.  
  354.  
  355. Private Function ComboRootAdd(sText$, lItemData&) As Long
  356.     Dim lNewIndex As Long
  357.     
  358.     cboRootSFN.AddItem CStr(lItemData) & " - " & sText
  359.     lNewIndex = cboRootSFN.NewIndex
  360.     cboRootSFN.ItemData(lNewIndex) = lItemData
  361.     ComboRootAdd = lNewIndex
  362. End Function
  363.  
  364. Private Sub Form_Unload(Cancel As Integer)
  365.     NSTree.AboutBox
  366. End Sub
  367.  
  368. Private Sub NSTree_Error(ByVal Number As Long, Message As String, Title As String, Retry As Boolean)
  369.     Call ShowEvent("NSTree_Error " & Message)
  370. End Sub
  371.  
  372. Private Sub NSTree_FolderChange()
  373.     Call ShowEvent("NSTree_FolderChange  " & NSTree.FolderName)
  374.     Call ShowProperies
  375. End Sub
  376.  
  377. Private Sub ShowEvent(sMsg$)
  378.     If Len(txtEvents) > 10000 Then txtEvents = Right$(txtEvents, 10000)
  379.     txtEvents.SelStart = Len(txtEvents)
  380.     txtEvents.SelText = sMsg & vbCrLf
  381. End Sub
  382.  
  383. Private Function DisplayIDL_s(vIDL) As String
  384.     Dim sTmp As String
  385.     Dim x As Long
  386.     Dim cnt As Integer
  387.     
  388.     For x = 0 To UBound(vIDL)
  389.         cnt = cnt + 1
  390.         sTmp = sTmp & Hex$(vIDL(x))
  391.         If cnt = 10 Then
  392.             sTmp = sTmp & vbCrLf
  393.             cnt = 0
  394.         Else
  395.             sTmp = sTmp & "-"
  396.         End If
  397.     Next
  398.     DisplayIDL_s = sTmp
  399. End Function
  400.  
  401.  
  402. Private Sub ComboSync(cbo As ComboBox, lItemData&)
  403.     Dim iIndex As Integer
  404.  
  405.     If cbo.ListIndex >= 0 Then
  406.         If cbo.ItemData(cbo.ListIndex) = lItemData Then Exit Sub
  407.     End If
  408.     For iIndex = 0 To cbo.ListCount - 1
  409.         If cbo.ItemData(iIndex) = lItemData Then
  410.             cbo.ListIndex = iIndex
  411.             Exit Sub
  412.         End If
  413.     Next
  414.     cbo.ListIndex = -1 'Not found
  415. End Sub
  416.  
  417. Private Sub ShowProperies()
  418.     lblFolderName = "FolderName: " & NSTree.FolderName
  419.     lblFolderAttributes = "FolderAttributes: " & Hex$(NSTree.FolderAttributes)
  420.     lblPath = NSTree.Path
  421.     lblFolderIDL = "FolderIDL: " & DisplayIDL_s(NSTree.FolderIDL)
  422.     
  423.     lblRootDIR = NSTree.RootDIR
  424.     lblRootIDL = "RootIDL: " & DisplayIDL_s(NSTree.RootIDL)
  425.     Call ComboSync(cboRootSFN, NSTree.RootSFN)
  426. End Sub
  427.  
  428. Private Sub NSTree_KeyDown(KeyCode As Integer, Shift As Integer)
  429.     Call ShowEvent("NSTree_KeyDown")
  430. End Sub
  431.  
  432. Private Sub NSTree_KeyPress(KeyAscii As Integer)
  433.     Call ShowEvent("NSTree_KeyPress")
  434. End Sub
  435.  
  436. Private Sub NSTree_KeyUp(KeyCode As Integer, Shift As Integer)
  437.     Call ShowEvent("NSTree_KeyUp")
  438. End Sub
  439.  
  440. Private Sub NSTree_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  441.     Call ShowEvent("NSTree_MouseDown")
  442. End Sub
  443.  
  444. Private Sub NSTree_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  445.     Call ShowEvent("NSTree_MouseUp")
  446. End Sub
  447.